/**
 * 埋点系统类型定义
 * @author lhx
 */

// 事件类型枚举
export enum EventType {
    CLICK = 'click',
    VIEW = 'view', 
    SCROLL = 'scroll',
    FORM = 'form',
    PAGE = 'page'
  }
  
  // 事件优先级
  export enum EventPriority {
    HIGH = 'high',
    MEDIUM = 'medium', 
    LOW = 'low'
  }
  
  // 基础事件属性
  export interface BaseEventProperties {
    [key: string]: any;
  }
  
  // 点击事件特有属性
  export interface ClickEventProperties extends BaseEventProperties {
    carId?: string;
    position?: number;
    buttonText?: string;
    elementType?: string;
    price?: number;
    brand?: string;
  }
  
  // 上下文信息
  export interface EventContext {
    page: string;
    module: string;
    platform: 'android' | 'ios';
    deviceId: string;
    appVersion: string;
    timestamp: number;
    sessionId: string;
    userId?: string;
    referrer?: string;
    experiment?: string;
  }
  
  // 埋点事件数据结构
  export interface TrackingEvent {
    id: string;
    eventName: string;
    eventType: EventType;
    priority: EventPriority;
    properties: BaseEventProperties;
    context: EventContext;
    timestamp: number;
    uploaded: boolean;
    retryCount: number;
  }
  
  // 点击事件数据结构
  export interface ClickTrackingEvent extends Omit<TrackingEvent, 'properties'> {
    properties: ClickEventProperties;
  }
  
  // 埋点配置
  export interface TrackingConfig {
    enabled: boolean;
    batchSize: number;
    uploadInterval: number;
    maxRetries: number;
    endpoint: string;
    debugMode: boolean;
  }
  
  // Redux State 结构
  export interface TrackingState {
    events: TrackingEvent[];
    config: TrackingConfig;
    currentSession: {
      sessionId: string;
      startTime: number;
      userId?: string;
      pageStack: string[];
    };
    uploadQueue: TrackingEvent[];
    isUploading: boolean;
    lastUploadTime: number;
  }
  
  // AsyncStorage 数据结构
  export interface StoredTrackingData {
    events: TrackingEvent[];
    session: {
      sessionId: string;
      startTime: number;
      userId?: string;
    };
    config: TrackingConfig;
    lastCleanupTime: number;
  }
  
  // 点击追踪器Props
  export interface ClickTrackerLhxProps {
    eventName: string;
    properties?: ClickEventProperties;
    priority?: EventPriority;
    disabled?: boolean;
    onTrack?: (event: ClickTrackingEvent) => void;
    children: React.ReactNode;
  }